﻿using System;
using System.Collections.Generic;
using System.ServiceModel.Activation;
using MoneyTracking.BLL;
using MoneyTracking.Common;

namespace MoneyTracking.Service
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class MoneyService : IMoneyService
    {
        public ServiceResponse AddExpense(Expense expense)
        {
            var response = new ServiceResponse();
            using (var manager = new ExpenseManager())
            {
                try
                {
                    response.Result = manager.AddExpense(expense);
                    response.IsSuccess = true;
                }
                catch (Exception exception)
                {
                    response.ServiceException = exception;
                    response.IsSuccess = false;
                    response.ErrorMessage = "Unable to add Expense";
                }
            }
            return response;
        }

        public ServiceResponse UpdateExpense(Expense expense)
        {
            var response = new ServiceResponse();
            return response;
        }

        public ServiceResponse DeleteExpense(Expense expense)
        {
            var response = new ServiceResponse();
            return response;
        }

        public ServiceResponse GetExpenseByID(int expenseId)
        {
            var response = new ServiceResponse();
            return response;
        }

        public ServiceResponse AddCategory(Category category)
        {
            var response = new ServiceResponse();
            response.IsSuccess = true;
            return response;
        }

        public ServiceResponse UpdateCategory(Category category)
        {
            var response = new ServiceResponse();
            return response;
        }

        public ServiceResponse DeleteCategory(Category category)
        {
            var response = new ServiceResponse();
            return response;
        }

        public ServiceResponse GetCategoryByID(int categoryId)
        {
            var response = new ServiceResponse();
            return response;
        }

        public ServiceResponse GetAllExpense()
        {
            var response = new ServiceResponse();
            var  manager = new ExpenseManager();
            List<Expense> allExpense = manager.GetAllExpense();
            response.Result = allExpense;
            return response;
        }
    }
}
